//# sourceURL=index.js
$(function(){
    layui.use(['form', 'layer', 'element'], function(){
        var form=layui.form
        ,layer = layui.layer //弹层
        ,element = layui.element; //元素操作
      //获取系统信息
        $.ajax({
	           url: "/sys/getSys.do",     //请求地址
	           type: "POST",              //请求类型
	          // data:formatParam(requestData),              //请求数据
	           timeout: 200000,                //请求超时时间(毫秒)
	           headers: setHeader(),
	           success:function(res){         //请求成功
	        	   $(".sysname").html(res.resultData.sys.sysName);	        	   
          }
       })
        //获取用户信息
        $.ajax({
               url: "/sysUser/getMyAllInfo.do",               //请求地址
               type: "POST",              //请求类型
              // data:formatParam(requestData),              //请求数据
               timeout: 200000,                //请求超时时间(毫秒)
               headers: setHeader(),
               success:function(res){         //请求成功
            	      $("#userName").html(res.resultData.userName);
            	      $("#userName").attr("title",res.resultData.userName);
            	      if(res.resultData.imageZh!=null&&res.resultData.imageZh!=""){
            	    	  $("#userimg").attr("src",res.resultData.imageZh);
            	      }else{
            	    	  $("#userimg").attr("src","/res/images/admin.jpg");
            	      }            	      
               }
        })
        //获取一级菜单   
  	  	$.ajax({
	           url: "/sysUser/getMyOnePower.do",               //请求地址
	           type: "POST", 
	           // async:false,//请求类型
	           timeout: 2000000,                //请求超时时间(毫秒)
	           headers: setHeader(),
	           success:function(res){   	        	
	        	 //请求成功      	        	      	        	         	        	   
	        	   if(res.status == 200)
	  				{
	        		   var data=res.resultData;
	        		   var html='';
	        		   $.each(data , function(i,json){
	        			         var colorArry=json["backgroundColor"];
	        			         var stylebg='';
			              		 if(colorArry==null){
			              			stylebg="background-color: rgba(172,195,194,0.6);"
			              		 }else{
			              			 var COLOR=JSON.parse(colorArry);
			              			 if(COLOR.length>0){
			              				stylebg="background-color:"+hexToRgba(COLOR[0],0.6)
			              			 }               		 
			              		 }
                                html+='<div class="layui-col-xs6 layui-col-sm6 layui-col-md4 LIcol">'+
								         '<a class="nav_list_box01 left" href="'+json["url"]+'?permissionId='+json["permissionId"]+'" style='+stylebg+'>'+
						                    '<img src='+json["iconZh"]+'/>'+
						                    '<span>'+json["name"]+'</span>'+
						                 '</a>'+
								       '</div>'	
	        		   })
	        		   $(".nav_list").append(html);
	  				}else{
	  					 layer.msg("数据请求错误！",{icon:5});
	  				}
	        	   form.render();
	  			} 	   
         })	
        form.render();
  	  	$(".i_member_click").hover(function(){
	  	  	if ($(this).next("dl").css('display') == 'block') {
		         $(this).css("border-right", "0px")
		  	 }else{
		  		 $(this).css("border-right", "2px solid #feed6e")
		  	 }  	        
  	         $(this).next("dl").toggle("slow");  	  	  		
  	  	})
  	//退出事件
  	  $('#logout').on("click", function(){
  		$(".i_member .i_member_child").hide("slow");
  		$(".i_member .i_member_click").css("border-right", "0px")
  	  	$.ajax({
  	             url: "/logout.do",               //请求地址
  	             type: "POST",              //请求类型
  	             timeout: 200000,                //请求超时时间(毫秒)
  	             headers: setHeader(),
  	             success:function(res){         //请求成功
  	          	   window.location = "/login.html"; 
  	           }
  	        })
  	   }); 
    });
});
function x_admin_show(title,url,w,h){
	 $(".i_member .i_member_child").hide("slow"); 
	 $(".i_member .i_member_click").css("border-right", "0px")
    if (title == null || title == '') {
        title=false;
    };
    if (url == null || url == '') {
        url="404.html";
    };
    if (w == null || w == '') {
        // w=($(window).width()*0.8);
		 w=600;
    };
    if (h == null || h == '') {
        // h=($(window).height() - 50);
		 h=400;
    };
    layer.open({
        type: 2,
        area: [w+'px', h +'px'], 
        fix: false, //不固定
        maxmin: true,
        shadeClose: true,
        shade:0.4, //遮罩层
        title: [title,'background:#1E9FFF;color:#fff'],
        content: '/res/page/changemessage/'+url
    });
}
//颜色十六进制转RGBA
function hexToRgba(hex, opacity) {
	  return "rgba(" + parseInt("0x" + hex.slice(1, 3)) + "," + parseInt("0x" + hex.slice(3, 5)) + "," + parseInt("0x" + hex.slice(5, 7)) + "," + opacity + ")"
}